package ui.frame.dialog;

import java.awt.event.ActionEvent;
import static constants.GTextbookConstants.language;

import ui.Utility;
import ui.frame.GTFrame;
import ui.frame.GTextbook;
import ui.view.NodeInfo;
import ui.view.GTView;
import ui.view.IndexTreeView;
import static constants.GTextbookConstants.knowledgeObject;

public class AddProofDialog extends ProofDialog{
	public AddProofDialog(GTextbook theApp, GTFrame window, int language){
		super(theApp, window, language);
	}
	
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource() == cancel){
			System.out.println("fsadfafa");
			setNewData(false);
			this.dispose();
		}
		if(e.getSource() == ok){
			setNewData(true);
			if(store("Proof")){
				String name = getBasicPanel().getNamePanel().getTextField().getText();
				NodeInfo NodeInfo = new NodeInfo("Proof", Utility.getKnowledgeNameFromInput(name), language.getNum());
				((IndexTreeView)(((GTView)(theApp.getView())).getIndexTabbedPane().getSelectedComponent())).getIndexTree().addObject(NodeInfo).setAllowsChildren(false);
				this.dispose();
			}
		}
	}
	
}
